package tech.aistar.corejava.day05.homework01.biz;

import tech.aistar.corejava.day05.homework01.Account;

/**
 * @author success
 * @version 1.0
 * @description:本类用来演示:银行账户的业务类
 * @date 2019/7/23 0023
 */
public class AccountBiz {
    //业务类和实体类合二为一的方式
    //业务方法仍然是在实体类中
    public void depoist(Account acc,double money){
        if(money<=0){
            System.out.println("sorry,必须要存入有效金额!");
            return;
        }
        //this.accBlance+=money;
        double d = acc.getAccBlance()+money;
        //重新设置余额
        acc.setAccBlance(d);
    }

    public void withdraw(Account acc,double money){
        if(money<=0 || money>acc.getAccBlance()){
            System.out.println("sorry,余额不足!");
            return;
        }
        //this.accBlance-=money;
        acc.setAccBlance(acc.getAccBlance() - money);
    }
}
